import feedparser;
import time;
from BlogElements import BlogPosting;

class SinaSeedParser:
    def parse(self, seedFilePath):
        postings = [];
        try:
            doc = feedparser.parse(seedFilePath);
            if not doc.has_key('entries'):
                return postings;
            entries = doc.entries;
            for entry in entries:
                posting = BlogPosting();
                posting.title = entry.title;
                posting.url = entry.link;
                posting.date = time.mktime(entry.updated_parsed);
                posting.description = entry.summary;
                postings.append(posting);
        except:
            return postings;
        return postings;

if __name__ == '__main__':
    import sys;
    parser = SinaParser();
    postings = parser.parse(sys.argv[1]);
    print postings[0];
